home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / e / mailinglists / amigae.0294feb.archive / 000030_donews!crash!kb…bt.co.uk!tonyp_Tue, 8 Feb 94 07:45:19 PST.msg < prev    next >
Internet Message Format  |  1994-05-26  |  13KB

  1. Received: by bkhouse.cts.com (V1.17-beta/Amiga)
  2.       id <1rf0@bkhouse.cts.com>; Tue, 8 Feb 94 07:45:19 PST
  3. Received: from crash by donews.cts.com with uucp
  4.     (Smail3.1.28.1 #18) id m0pTeLu-0001OoC; Mon, 7 Feb 94 14:22 PST
  5. Received: from zaphod.axion.bt.co.uk by crash.cts.com with smtp
  6.     (Smail3.1.28.1 #18) id m0pTSE6-0000awC; Mon, 7 Feb 94 01:25 PST
  7. Received: from jasper.kbss.bt.co.uk (actually 132.146.9.31) by zaphod.axion.bt.co.uk with SMTP (PP);
  8.           Mon, 7 Feb 1994 09:16:20 +0000
  9. Received: from olivine.kbss.bt.co.uk by jasper.kbss.bt.co.uk; Mon, 7 Feb 94 09:14:56 GMT
  10. Date: Mon, 7 Feb 94 09:14:54 GMT
  11. Message-Id: <1122.9402070914@olivine.kbss.bt.co.uk>
  12. From: Tony Prichard 293834 <tonyp@kbss.bt.co.uk>
  13. To: amigae@bkhouse.cts.com
  14. Subject: <none>
  15.  
  16. SUBSCRIBE AmigaE
  17. HELP AmigaE
  18. FAQ AmigaE
  19. From donews!crash!archiduc.irit.fr!vintenat Tue, 8 Feb 94 07:45:32 PST
  20. Received: by bkhouse.cts.com (V1.17-beta/Amiga)
  21.       id <1rf8@bkhouse.cts.com>; Tue, 8 Feb 94 07:45:32 PST
  22. Received: from crash by donews.cts.com with uucp
  23.     (Smail3.1.28.1 #18) id m0pTeM1-0001UFC; Mon, 7 Feb 94 14:22 PST
  24. Received: from archiduc.irit.fr by crash.cts.com with smtp
  25.     (Smail3.1.28.1 #18) id m0pTSKe-00017iC; Mon, 7 Feb 94 01:32 PST
  26. Received: from localhost (vintenat@localhost) by archiduc.irit.fr (8.6.4/8.6.4) id KAA12055; Mon, 7 Feb 1994 10:31:40 GMT
  27. Date: Mon, 7 Feb 1994 10:31:40 GMT
  28. Message-Id: <199402071031.KAA12055@archiduc.irit.fr>
  29. From: Lionel VINTENAT <vintenat@archiduc.irit.fr>
  30. To: amigae@bkhouse.cts.com
  31. Cc: vaald@westminster.ac.uk
  32. Subject: Re: I`m new here!
  33.  
  34. >   Not to mention DoMethod() in amiga.lib... I tried disassembling this but
  35. >   I don`t know too much about how the C stubs work, so I got lost... :(
  36. >   Anyway, any help in getting around these problems would be appreciated...
  37.  
  38.     Wouter gave me a doMethod() function for Amiga E which works very
  39. well, I'll e-mail it to you tomorrow. Does anybody else want it ?
  40.  
  41. >2: I have had some joy with MUI, I got a basic window with some text up
  42. >   and running, but nothing else... no DoMethod()! Gah!
  43.  
  44.     I wrote a macro preprocessor for Amiga E with MUI macros as example.
  45. It's called Mac2E. E-mail me for more details.
  46.  
  47. >Finally, has anyone got any tips for reading tooltypes? My efforts crash the
  48. >system, but I don`t have the source at hand :(
  49.  
  50.     I began a long time ago a program which needed tooltype reading. I gave
  51. up this program (for the moment), but I can send to you the parts that you
  52. are interested in. But the comments are in French !
  53.  
  54.     Lionel
  55. From donews!crash!sheffield.ac.uk!D.Lamptey Tue, 8 Feb 94 07:45:41 PST
  56. Received: by bkhouse.cts.com (V1.17-beta/Amiga)
  57.       id <1rfd@bkhouse.cts.com>; Tue, 8 Feb 94 07:45:41 PST
  58. Received: from crash by donews.cts.com with uucp
  59.     (Smail3.1.28.1 #18) id m0pTeM3-0001P9C; Mon, 7 Feb 94 14:22 PST
  60. Received: from sun2.nsfnet-relay.ac.uk by crash.cts.com with smtp
  61.     (Smail3.1.28.1 #18) id m0pTSUu-00013oC; Mon, 7 Feb 94 01:43 PST
  62. Received: from ntsc.shef.ac.uk by pp.shef.ac.uk with SMTP (PP) 
  63.           id <27153-0@pp.shef.ac.uk>; Mon, 7 Feb 1994 09:38:09 +0000
  64. Received: from mars.nattrans.COM by ntsc.shef.ac.uk (4.1/Derryck 1.1(mm)) 
  65.           id AA10869; Mon, 7 Feb 94 09:39:51 GMT
  66. Received: by mars.nattrans.COM (4.1/Derryck 1.2(sm)) id AA00601;
  67.           Mon, 7 Feb 94 09:45:02 GMT
  68. Via: uk.ac.sheffield; Mon, 7 Feb 1994 09:42:22 +0000
  69. Date: Mon, 7 Feb 94 09:45:02 GMT
  70. Message-Id: <9402070945.AA00601@ntsc.shef.ac.uk>
  71. From: D.Lamptey@sheffield.ac.uk
  72. To: AmigaE@bkhouse.cts.com
  73. Subject: Re: STOP PRESS!!!
  74.  
  75.  
  76. ]
  77. ]Amiga E has a double page feature in Amiga Shopper this month, March 
  78. ]issue, pages 62/63.
  79. ]
  80. ]Here are the contents of the "Checkout" box at the end of the article.
  81. ]
  82. (Good News...)
  83. ]
  84. ]----8<----8<----8<----
  85. ]
  86. ]The reviewer is called Jason Hulance (are you on this mailing list, 
  87. ]Jason? :-)
  88. ]
  89.  
  90. Yes, Jason is on this list, and contributes frequently.
  91.  
  92. Good to see you made it, Jason!
  93. (Please e-mail me, wanna talk to you..)
  94.  
  95.  
  96. Derryck.
  97. _____________________________________________________________
  98. Derryck Lamptey, MSc(Eng): National Transputer Support Centre   
  99. D.Lamptey@sheffield.ac.uk  Evening  voice:  (+44/0)742 309165
  100. From donews!crash!mars.let.uva.nl!wouter Tue, 8 Feb 94 07:46:28 PST
  101. Received: by bkhouse.cts.com (V1.17-beta/Amiga)
  102.       id <1rgd@bkhouse.cts.com>; Tue, 8 Feb 94 07:46:28 PST
  103. Received: from crash by donews.cts.com with uucp
  104.     (Smail3.1.28.1 #18) id m0pTeMQ-0002ScC; Mon, 7 Feb 94 14:23 PST
  105. Received: from uranus.let.uva.nl by crash.cts.com with smtp
  106.     (Smail3.1.28.1 #18) id m0pTWaj-0000LPC; Mon, 7 Feb 94 06:05 PST
  107. Received: by uranus.let.uva.nl id AA01869
  108.   (5.65c/IDA-1.4.4 for AmigaE@bkhouse.cts.com); Mon, 7 Feb 1994 15:00:04 +0100
  109. Return-Path: <wouter@mars.let.uva.nl>
  110. Date: Mon, 7 Feb 1994 15:00:04 +0100
  111. Message-Id: <199402071400.AA01869@uranus.let.uva.nl>
  112. X-Organisation: Department of Computational Linguistics,
  113.                 University of Amsterdam
  114.                 Spuistraat 134, 1012 VB Amsterdam, The Netherlands
  115. From: Wouter van Oortmerssen <wouter@mars.let.uva.nl>
  116. To: AmigaE@bkhouse.cts.com
  117. Subject: Types!
  118.  
  119.  
  120. Hello All,
  121.  
  122. Here is yet another text I wrote with the purpose to help people
  123. understand E better. It's a first version, so needs improvement. Enjoy!
  124.  
  125. ---------------------------------------------------------------------------
  126.  
  127.  
  128.  
  129.                          UNDERSTANDING E TYPES
  130.  
  131.                        by Wouter van Oortmerssen
  132.  
  133.  
  134.  
  135. Intro
  136. -----
  137.  
  138. Most problems people have while programming in E stem from their incorrect
  139. view of how the E type-system works, and, admitted, this is not surprising
  140. given the way it is described in the reference manual. Also, many people
  141. have an idea how types work from their previous programming language, and
  142. try to apply this to E, which is often fatal, because E is quite different
  143. when it come to types.
  144.  
  145.  
  146. The Type System
  147. ---------------
  148.  
  149. This may come as a shock to some readers, but E is in essense a TYPELESS
  150. language. Indeed, variables may have a type, but this is only used as a
  151. specification how to dereference a variable when it is used as a pointer.
  152. In almost ALL other language constructions, variables are treated as all
  153. being of the same type, namely the famous 32bit typeless value.
  154.  
  155. In practise this means that for example in expressions with the exception
  156. of the ".", "[]" and "++" operators etc., all operators and functions work
  157. on 32bit values, regardless of wether they represent booleans, integers,
  158. reals or pointers to something.
  159.  
  160.  
  161. So what are those Pointer Types?
  162. --------------------------------
  163.  
  164. In the E type-system only 4 types exist, PTR TO CHAR, PTR TO INT,
  165. PTR TO LONG and PTR TO <object>, where <object> is a name of a previously
  166. defined OBJECT. When a variable (or an object member, as we'll see later)
  167. is declared as being of this type, It means that if the variable contains
  168. a value that is a legal pointer, this is how it should be dereferenced.
  169.  
  170.  
  171. And what about LONG, ARRAY etc. ?
  172. ---------------------------------
  173.  
  174. All other types one may see in a DEF declaration a not really types, as
  175. they really are only other ways of writing one of the above four. As an
  176. example, ARRAY OF <type> is just another way of writing PTR TO <type>, with
  177. the only difference that the former is automatically assigned the address
  178. of an area of stackspace which is big enough to hold data for the #of
  179. elements specified in square brackets.
  180.  
  181. Here's a table that shows all E 'types' in terms of the basic four:
  182.  
  183. ARRAY OF CHAR, ARRAY, STRING, LONG, <>   (are equal to)   PTR TO CHAR
  184. ARRAY OF INT                             (is equal to)    PTR TO INT
  185. ARRAY OF LONG, LIST                      (are equal to)   PTR TO LONG
  186. ARRAY OF <object>, <object>              (are equal to)   PTR TO <object>
  187.  
  188. with "<>" I mean: no type specification at all.
  189.  
  190. - LONG is for variables that are not intended to be used as a pointer,
  191.   i.e integers. It's equivalence with PTR TO CHAR is quite logical, as
  192.   conceptually both talk about things that are measured in units of 1.
  193.   (for example, "++" has the same effect on both)
  194. - LIST and STRING are the same as their ARRAY equivalents, in respect
  195.   to the fact that they're initialised to a piece of stack-space, but
  196.   they're stack representation is a little more complex to facilitate
  197.   runtime bounds-checking (when used with the correct functions).
  198. - an <object> is equivalent to [1]:ARRAY OF <object>. both represent
  199.   an initialised PTR TO <object>.
  200.  
  201. In an OBJECT one can have the same declarations, with the addition of CHAR
  202. and INT (similar to LONG), and the ommission of LIST and STRING, as these
  203. are complex objects in their own right, and cannot be part of an object.
  204. (NOTE: in versions of E previous to v3.0, PTR TO and ARRAY OF types were
  205. not available in OBJECTS)
  206.  
  207.  
  208. Deferencing
  209. -----------
  210.  
  211. Given a pointer p of some type,
  212.  
  213. "[]" may index other elements that are sequentially ordered next to
  214.      the element it is currently pointing to. note that this allows for
  215.      both positive and negative indices, and also no assumptions are made
  216.      about where and howmany elements are actually allocated.
  217.  
  218. "++" sets the pointer to the next element in memory, "--" to the previous
  219.      one. note that these operators always operate on the pointer and
  220.      never on the the element the pointer is pointing to.
  221.  
  222. "."  works similar to "[]", only now indexes the pointer by name, i.e. the
  223.      pointer must be a PTR TO <object>.
  224.  
  225. "[]" and "." may be concatenated to a pointer p in any sequence, given the
  226. fact that the previous resulting value again is known to be of a "PTR TO"
  227. type. (note that in versions of E previous to v3.0, this was restricted to
  228. one "[]" and then one ".", notably because OBJECTs couldn't have PTRs in
  229. them)
  230.  
  231. One does not need to write out a de-reference in total, as in other
  232. languages, e.g. if p is an ARRAY OF obj, instead of having to write
  233. p[index].member you can write just p[index], which logically results
  234. in in the address of that object. This also explains why p[].member
  235. is equivalent to p.member, since p[] is the same as p when it points
  236. to an object.
  237.  
  238.  
  239. Reference Semantics
  240. -------------------
  241.  
  242. Another type-related issue that makes E somewhat different from other
  243. languages and thus harder to grasp is it's accent on Reference Semantics
  244. rather than Value Semantics. I'll try to argue why that's good here.
  245.  
  246. Informally, Reference Semantics means that objects in a language (mostly
  247. other than the simple ones like LONGs) are represented by pointers, while
  248. Value Semantics treats these objects as just being themselves. An example
  249. of a language that has only Value Semantics is BASIC, examples of
  250. languages that have them both are the C/C++ and Pascal type-of languages,
  251. and examples of Reference only are newer Object Oriented languages like
  252. Eiffel, functional languages like LISP and ofcourse E.
  253.  
  254. Using Reference Semantics doesn't mean being occupied with pointers
  255. all the time, rather you're worrying about them a lot less then in the
  256. mixed case or the Value-only case, especially since in real life programs
  257. most non-trivial data-structures get allocated dynamically which implies
  258. pointers. The best example of this is LISP, where one programs heavily
  259. with pointers without noticing. In E, one could easily forget STRING
  260. is a pointer, given the easy by which one can pass it around to other
  261. functions; in C often lots of "&" are needed where in the equivalent E
  262. case non are, and the Oberon equivalent of bla('hallo') looks like
  263. bla(sys.ADR('hallo')) because the string doesn't represent a pointer,
  264. but a value as a whole...
  265.  
  266. So why do languages have Value Semantics? beats me. One may thinks it's
  267. conceptually nice but I can't imagine. A stronger argument seems to be
  268. that accesses to objects that are no pointers can be better optimised by
  269. a good compiler, but since only very trivial and static data-structures
  270. can be build in this fashion, it's hardly an issue. Value semantics
  271. is old-fashioned and will probably loose significance in new and upcoming
  272. languages.
  273.  
  274. <note: this needs less hype>
  275.  
  276.  
  277. Comparisons with C
  278. ------------------
  279.  
  280. long *x;                x:PTR TO LONG
  281. long x[10];                --
  282. long dummy[10], *x=&dummy;        x[10]:ARRAY OF LONG
  283.  
  284. <note: more here>
  285.  
  286. (-- = not possible, because of value-semantics)
  287.  
  288.  
  289. Often Made Mistakes
  290. -------------------
  291.  
  292. DEF s[50]:STRING
  293. s:='bla'
  294.  
  295. This does not get the 'bla' into the string, however there's nothing
  296. wrong with it either, just not what programmer means. The expression
  297. on the righthandside of the ":=" results in a pointer, and replaces the
  298. pointer that was already in s, namely one to an empty STRING. To actually
  299. make a copy of 'bla' instead of just moving the pointer around (which
  300. is desired in 90% of the cases), use StrCopy().
  301.  
  302. <note: more examples here>
  303.  
  304.  
  305. Conclusions: So does Strong-Typing suck?
  306. ----------------------------------------
  307.  
  308. Yes and no.
  309. <note: explanation here>